/****************************************************
	文件：UIComps.cs
	作者：HuskyT
	邮箱：1005240602@qq.com
	日期：2020/9/26 1:26:52
	功能：UI组件
*****************************************************/

using System;
using System.Collections.Generic;
using UnityEngine;

namespace RedSpotSystem
{
    /// <summary>
    /// UI组件
    /// </summary>
    public class UIComps
    {
        /// <summary>
        /// 组件字典（通过 InitUIComponents 得到的）
        /// </summary>
        private Dictionary<string, UnityEngine.Object> mComps;

        public UIComps(GameObject selfGo)
        {
            mComps = new Dictionary<string, UnityEngine.Object>();
            UIManager.Instance.InitUIComponents(ref mComps, selfGo);
        }

        /// <summary>
        /// 获取通过 InitUIComponents 得到的 UI 组件
        /// 
        /// </summary>
        /// <typeparam name="T">UI组件类型</typeparam>
        /// <param name="compName">UI名称</param>
        /// <returns></returns>
        public T Get<T>(string compName) where T : UnityEngine.Object
        {
            return mComps[compName] as T;
        }
    }
}
